#!/usr/bin/python
#
# absynth.py
# Copyright (C) Nicola Bizzoca   2006  <hannibal_smith@users.sourceforge.net>
# Copyright (C) Simone Economo   2006  <ekoes@users.sourceforge.net>
# 
# Absynth  is free software.
# 
# You may redistribute it and/or modify it under the terms of the
# GNU General Public License, as published by the Free Software
# Foundation; either version 2 of the License, or (at your option)
# any later version.
# 
# main.py is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with main.py.  If not, write to:
#     The Free Software Foundation, Inc.,
#     51 Franklin Street, Fifth Floor
#     Boston, MA  02110-1301, USA.

try:
    import gtk, gtk.glade
except ImportError:
    print >> sys.stderr, 'Absynth needs GTK 2.10 or above to run.'
    sys.exit(1)
import conf
import os, sys

sys.path.append(os.path.join(os.getcwd(), "widgets"))
from widgets import *
#import widgets as WidgetsPackage

sys.path.append(os.path.join(os.getcwd(), "lib"))
import filesmime as mimetypes
import libftp as FTPEngine
    
class Widgets:
	def __init__(self):
		self.glade = gtk.glade.XML(conf.GLADE_MAIN_WINDOW)
        
	def connect(self):
		events = {
			"on_about" : 					self.select["AboutDialog"].Main,
			"on_AbsynthMain_destroy" : 		gtk.main_quit,
		}
		self.glade.signal_autoconnect(events)
    
	def get(self, widget): return self.glade.get_widget(widget)
	
	def store(self):
		self.select = {
			"LocalView": 	LocalView,
			"RemoteView": 	RemoteView,
			"AboutDialog": 	AboutDialog,
			"SysTray":		SysTray,
			"LogView":		LogView,
		}
 		
class UIEngine:
    _instance = None
    def __init__(self):
		self.widgets = Widgets()
		self.widgets.store()
		#self.widgets.connect()
		self.__WindowInit()
        
    def __WindowInit(self):
		self.__mainWindow = self.widgets.get(conf.WINDOW_TYPE)
		self.__mainWindow.set_title("%s %s" % (conf.APP_NAME, conf.APP_VERSION))
		self.__mainWindow.set_icon_from_file(conf.DATA_DIR + "/img/logo_minimal.png")
        
    def mainLoop(self):
		gtk.main()
